<?php
use yii\helpers\Url;
?>
<?php $this->beginBlock('content') ?>
<div class="row">
    <div class="col-sm-12">
        <div class="white-box">
            <h3 class="box-title"></h3>
            <div class="row m-b-15">
                <div class="col-sm-12">
                    <form action="">
                        <div class="row">
                            <div class="col-sm-4">
                                <div class="input-daterange input-group">
                                    <input type="text" class="form-control" name="start" value="<?=Yii::$app->request->get('start') ?>" autocomplete="off" placeholder="" />
                                    <span class="input-group-addon bg-info b-0 text-white">to</span>
                                    <input type="text" class="form-control" name="end" value="<?=Yii::$app->request->get('end') ?>" autocomplete="off" placeholder="" />
                                </div>
                            </div>
                            <div class="col-sm-2">
                                <select class="selectpicker m-b-20 m-r-10" name="plug" data-style="form-control">
                                    <option>选择业务</option>
                                    <?php foreach ($plugMap as $item): ?>
                                        <option value="<?=$item['id']?>" <?=Yii::$app->request->get('plug') == $item['id'] ? 'selected' : ''?>><?=$item['name']?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="selectpicker m-b-20 m-r-10" name="type" data-style="form-control">
                                    <option value="1" <?=Yii::$app->request->get('type') == '1' ? 'selected' : ''?>>代理商ID</option>
                                    <option value="2" <?=Yii::$app->request->get('type') == '2' ? 'selected' : ''?>>代理账号</option>
                                    <option value="3" <?=Yii::$app->request->get('type') == '3' ? 'selected' : ''?>>代理商名称</option>
                                    <option value="4" <?=Yii::$app->request->get('type') == '4' ? 'selected' : ''?>>区域经理名称</option>
                                </select>
                            </div>
                            <div class="col-sm-4">
                                <div class="input-group">
                                    <input type="text" class="form-control m-r-5" name="keyword" value="<?=Yii::$app->request->get('keyword')?>" placeholder="关键词">
                                    <span class="input-group-btn">
                                        <button class="btn btn-info" type="submit">
                                            搜索
                                        </button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>业务名称</th>
                        <th>累计终端数</th>
                        <th>代理商名称</th>
                        <th>区域经理名称</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($plugsRunTotalList as $item): ?>
                        <tr>
                            <td><?=$plugMap[$item['plug_id']]['name'] ?? ''?></td>
                            <td><?=$item['terminal_num_sum'] ?: ''?></td>
                            <td><?=$adminMap[$item['agent_id']]['username'] ?? ''?></td>
                            <td><?=$adminMap[$item['manager_id']]['username'] ?? ''?></td>
                            <td>
                                <a href="<?=Url::to([
                                    'detail-line',
                                    'agent_id' => $item['agent_id'],
                                    'manager_id' => $item['manager_id'],
                                    'plug_id' => $item['plug_id'],
                                    'start' => Yii::$app->request->get('start'),
                                    'end' => Yii::$app->request->get('end'),
                                ])?>" data-toggle="tooltip" data-original-title="图表"> 图表 </a>
                                <a href="<?=Url::to([
                                    'detail-area',
                                    'agent_id' => $item['agent_id'],
                                    'manager_id' => $item['manager_id'],
                                    'plug_id' => $item['plug_id'],
                                    'start' => Yii::$app->request->get('start'),
                                    'end' => Yii::$app->request->get('end'),
                                ])?>" data-toggle="tooltip" data-original-title="地区数据"> 地区数据 </a>
                            </td>
                        </tr>
                    <?php endforeach ?>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="14" class="footable-visible">
                            <div class="text-right">
                                <?=\common\components\DataHelper::getLinkPager($page)?>
                            </div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $this->endBlock()?>
<?php $this->beginBlock("script")?>
<script>
    laydate.render({
        type: 'date',
        elem: 'input[name="start"]',
        max: '<?=date('Y-m-d')?>',
    });
    laydate.render({
        type: 'date',
        elem: 'input[name="end"]',
        max: '<?=date('Y-m-d')?>',
    });
</script>
<?php $this->endBlock(); ?>
